// SINGULARITY HTML5 GAME ENGINE
// -----------------------------
// Copyright(c) 2013 by Codenova.pl

define(['../Core'], function (Core) {
    var Form = function(objForm) {
        "use strict";
        this.Background = objForm.Background;
        this.BorderColor = objForm.BorderColor;
        this.BorderWidth = objForm.BorderWidth;
        this.Height = objForm.Height;
        this.Hoverable = false;
        this.Id = Core.GenerateUUID();
        this.Inputs = objForm.Inputs;
        this.Width = objForm.Width;
        this.X = objForm.X;
        this.Y = objForm.Y;
    };

    Form.prototype = {
        constructor: Form,

        Add: function() {
            "use strict";
            var _i, _length;

            // Draw form rectangle
            Core.DrawRectangle(this.Context, this.X, this.Y, this.Width, this.Height, this.Background, this.BorderColor, this.BorderWidth);

            // Iterate through form elements and draw them
            for(_i = 0, _length = this.Inputs.length - 1; _i <= _length; _i = _i + 1) {
                this.Inputs[_i].Initialize();
                this.Inputs[_i].Add();
            }
        },

        Create: function(objForm) {
            "use strict";
            return new Form(objForm);
        },

        Initialize: function() {
            Core.CreateCanvasForElement(this);
        }
    };

    return Form.prototype.Create;
});